use axum::routing::{post, get};
use crate::core::AppState;
use crate::controllers::backend::{
    home_controller,
    config_controller,
    advert_position_controller,
    advert_controller,
    category_controller,
    blog_controller,
    taxon_controller,
    product_controller,
    collect_type_controller,
    collect_controller,
    upload_controller,
    admin_controller,
    auth_controller
};

pub fn backend_router() -> axum::Router<AppState> {
    let router = axum::Router::new()
    // 首页
    .route("/dashboard", get(home_controller::dashboard_handler))
    // 配置
    .route("/config/edit", get(config_controller::edit_config_handler).post(config_controller::update_config_handler))
    // 文章分类
    .route("/category/list", get(category_controller::categorys_handler))
    .route("/category/create", get(category_controller::add_category_handler).post(category_controller::create_category_handler))
    .route("/category/edit/:id", get(category_controller::edit_category_handler).post(category_controller::update_category_handler))
    .route("/category/delete/:id", post(category_controller::delete_category_handler))
    // 文章
    .route("/blog/list", get(blog_controller::blogs_handler))
    .route("/blog/create", get(blog_controller::add_blog_handler).post(blog_controller::create_blog_handler))
    .route("/blog/edit/:id", get(blog_controller::edit_blog_handler).post(blog_controller::update_blog_handler))
    .route("/blog/delete/:id", post(blog_controller::delete_blog_handler))
    // 产品分类
    .route("/taxon/list", get(taxon_controller::taxons_handler))
    .route("/taxon/create", get(taxon_controller::add_taxon_handler).post(taxon_controller::create_taxon_handler))
    .route("/taxon/edit/:id", get(taxon_controller::edit_taxon_handler).post(taxon_controller::update_taxon_handler))
    .route("/taxon/delete/:id", post(taxon_controller::delete_taxon_handler))
    // 产品
    .route("/product/list", get(product_controller::products_handler))
    .route("/product/create", get(product_controller::add_product_handler).post(product_controller::create_product_handler))
    .route("/product/edit/:id", get(product_controller::edit_product_handler).post(product_controller::update_product_handler))
    .route("/product/delete/:id", post(product_controller::delete_product_handler))
    // 收藏分类
    .route("/collect_type/list", get(collect_type_controller::collect_types_handler))
    .route("/collect_type/create", get(collect_type_controller::add_collect_type_handler).post(collect_type_controller::create_collect_type_handler))
    .route("/collect_type/edit/:id", get(collect_type_controller::edit_collect_type_handler).post(collect_type_controller::update_collect_type_handler))
    .route("/collect_type/delete/:id", post(collect_type_controller::delete_collect_type_handler))
    // 收藏
    .route("/collect/list", get(collect_controller::collects_handler))
    .route("/collect/create", get(collect_controller::add_collect_handler).post(collect_controller::create_collect_handler))
    .route("/collect/edit/:id", get(collect_controller::edit_collect_handler).post(collect_controller::update_collect_handler))
    .route("/collect/delete/:id", post(collect_controller::delete_collect_handler))
    // 广告位
    .route("/adv_position/list", get(advert_position_controller::advert_positions_handler))
    .route("/adv_position/create", get(advert_position_controller::add_advert_position_handler).post(advert_position_controller::create_advert_position_handler))
    .route("/adv_position/edit/:id", get(advert_position_controller::edit_advert_position_handler).post(advert_position_controller::update_advert_position_handler))
    .route("/adv_position/delete/:id", post(advert_position_controller::delete_advert_position_handler))
    // 广告
    .route("/advert/list", get(advert_controller::adverts_handler))
    .route("/advert/create", get(advert_controller::add_advert_handler).post(advert_controller::create_advert_handler))
    .route("/advert/edit/:id", get(advert_controller::edit_advert_handler).post(advert_controller::update_advert_handler))
    .route("/advert/delete/:id", post(advert_controller::delete_advert_handler))
    // 管理员
    .route("/admin/list", get(admin_controller::admins_handler))
    .route("/admin/create", get(admin_controller::add_admin_handler).post(admin_controller::create_admin_handler))
    .route("/admin/edit/:id", get(admin_controller::edit_admin_handler).post(admin_controller::update_admin_handler))
    .route("/admin/profile", get(admin_controller::detail_admin_handler))
    .route("/admin/delete/:id", post(admin_controller::delete_admin_handler))
    // 上传
    .route("/upload", post(upload_controller::upload_handler))
    // 登录
    .route("/login", get(auth_controller::login_handler).post(auth_controller::login_in_handler))
    .route("/logout", get(auth_controller::logout_handler));
  
   
    router
}